package com.Algorithm.HUAWEI.four20220505;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: zjz
 * @Date: 2022/05/10/13:25
 * @Description:
 * @Target:
 */
public class MP3光标位置 {
   // 明了的是，1.当前显示，默认为1。   2.最上翻页到最后，最下翻页到最上， 3.当页展示4个。且随着上一步的进行而变化（最上，最下）
 // 1-5  UU 然后是4 那么展示应该是2-5
    // 临界点0,length-1,3，length-4


    public static void main(String[] args) throws Exception{

        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int num = Integer.valueOf(in.readLine());
        String commond = in.readLine();

        if (num>=4){
            process1(commond,num);
        }else {
            process2(commond,num);
        }
    }


    // 处理四位数的
    static void process1(String commond,int num){
        int[] ints = new int[num];
        for (int i = 1; i <= num; i++) {
            ints[i-1] = i;
        }

        ArrayList<Integer> memory = new ArrayList();
        memory.add(ints[0]);
        memory.add(ints[1]);
        memory.add(ints[2]);
        memory.add(ints[3]);
        int len = ints.length;
        int index = 0;
        for (int i = 0; i < commond.length(); i++) {
            index = index % len;
            if (commond.charAt(i)=='D'){
                index++;
                if (index % len >0 && !memory.contains(ints[index % len])){
                    memory.remove(0);
                    memory.add(ints[index % len]);
                }else if (index % len < -1  && !memory.contains(ints[ints.length+(index % len)])){
                    memory.remove(0);
                    memory.add(ints[ints.length+(index % len)]);
                }

            }else if (commond.charAt(i)=='U'){
                index--;
                if (index % len >0 && !memory.contains(ints[index % len])){
                    memory.remove(3);
                    memory.add(0,ints[index % len]);
                }else if (index % len < -1  && !memory.contains(ints[ints.length+(index % len)])){
                    memory.remove(3);
                    memory.add(0,ints[ints.length+(index % len)]);
                }
            }

            if (index % len==0){
                memory.clear();
                memory.add(ints[0]);
                memory.add(ints[1]);
                memory.add(ints[2]);
                memory.add(ints[3]);
            }else   if (index % len == -1){
                memory.clear();
                memory.add(ints[ints.length-4]);
                memory.add(ints[ints.length-3]);
                memory.add(ints[ints.length-2]);
                memory.add(ints[ints.length-1]);
            }

            System.out.println(i+" "+commond.charAt(i)+" "+index+" "+memory.toString());
        }


        System.out.println(memory.get(0)+" "+memory.get(1)+" "+memory.get(2)+" "+memory.get(3));

        if (index>=0){
            System.out.println(ints[index%len]);
        }else {
            if (index%len == 0){
                System.out.println(ints[0]);
            }else {
                System.out.println(ints[ints.length+(index%len)]);
            }
        }

    }


    // 处理小于四位数的
    static void process2(String commond,int num){
        int index = 0;
        if (num == 1){
            System.out.println("1");
            System.out.println("1");
        }else if (num == 2){
            System.out.println("1 2");
            for (int i = 0; i < commond.length(); i++) {
                if (commond.charAt(i)=='D'){
                    index++;
                }else {
                    index--;
                }
            }
            if (index%2==0){
                System.out.println("1");
            }else {
                System.out.println("2");
            }
        }else {
            System.out.println("1 2 3");
            for (int i = 0; i < commond.length(); i++) {
                if (commond.charAt(i)=='D'){
                    index++;
                }else {
                    index--;
                }
            }
            if (index%3==0){
                System.out.println("1");
            }else if (index%3==1 || index%3==-2){
                System.out.println("2");
            }else if (index%3==2 || index%3==-1){
                System.out.println("3");
            }

        }
    }
}


